#include<iostream>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int arr[100000] ;
	int i;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int j = 0,num1=0,num2=0; j < m; j++) {
		cin >> num1 >> num2;
		int x = arr[num1 - 1];
		for (int j=num1-1; j<num2; j++) {
			if (arr[j] < x) {
				x = arr[j];
			}
		}
		cout << x << endl;
	}
	return 0;
}